package reflect;


import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class cla = Class.forName("reflect.Person");
        Constructor c = cla.getConstructor(String.class,int.class);
        Object obj = c.newInstance("李四",22);
        System.out.println(obj);
        Constructor con = cla.getConstructor();
        Object obj1 = con.newInstance();
        System.out.println(obj1);


    }
}
